package com.health.controller;

import com.health.pojo.Users;
import com.health.service.HealthComboService;
import com.health.service.UserService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

// 查询用户下拉框（体检指标上传）
@WebServlet("/searchUser")
public class SearchUserServlet extends HttpServlet {
    UserService userService = new UserService();
    HealthComboService healthComboService = new HealthComboService();

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 查询出所有用户信息封装到User实体（返回list集合）
        List<Users> usersList = userService.searchUserInformation();

        request.setAttribute("index", request.getParameter("index"));
        // 将集合数据放到请求域中
        request.setAttribute("usersList", usersList);

        // 设置侧边栏状态
        request.setAttribute("asideStatus", 1);
        request.setAttribute("openInputView", -1);
        // 转发到admin.jsp页面
        request.getRequestDispatcher("/restrictedPages/admin.jsp").forward(request, response);


    }


    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
